package xmlasm.dto;

import java.math.BigInteger;
import java.util.ArrayList;
import java.util.Date;
import java.util.List;
import javax.xml.bind.annotation.XmlAccessType;
import javax.xml.bind.annotation.XmlAccessorType;
import javax.xml.bind.annotation.XmlElement;
import javax.xml.bind.annotation.XmlSchemaType;
import javax.xml.bind.annotation.XmlType;
import javax.xml.datatype.XMLGregorianCalendar;

/**
 * <p>Java class for feed complex type.
 * 
 * <p>The following schema fragment specifies the expected content contained within this class.
 * 
 * <pre>
 * &lt;complexType name="feed">
 *   &lt;complexContent>
 *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *       &lt;sequence>
 *         &lt;element name="feedId" type="{http://www.w3.org/2001/XMLSchema}positiveInteger"/>
 *         &lt;element name="url" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="title" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="decription" type="{http://www.w3.org/2001/XMLSchema}string"/>
 *         &lt;element name="addedDate" type="{http://www.w3.org/2001/XMLSchema}dateTime"/>
 *         &lt;element name="userlist">
 *           &lt;complexType>
 *             &lt;complexContent>
 *               &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
 *                 &lt;sequence>
 *                   &lt;element name="userId" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" maxOccurs="unbounded"/>
 *                 &lt;/sequence>
 *               &lt;/restriction>
 *             &lt;/complexContent>
 *           &lt;/complexType>
 *         &lt;/element>
 *       &lt;/sequence>
 *     &lt;/restriction>
 *   &lt;/complexContent>
 * &lt;/complexType>
 * </pre>
 * 
 * 
 */
@XmlAccessorType(XmlAccessType.FIELD)
@XmlType(name = "feed", propOrder = {
    "feedId",
    "url",
    "title",
    "decription",
    "addedDate",
    "userlist"
})
public class Feed {

    @XmlElement(required = true)
    @XmlSchemaType(name = "positiveInteger")
    protected int feedId;
    @XmlElement(required = true)
    protected String url;
    @XmlElement(required = true)
    protected String title;
    @XmlElement(required = true)
    protected String decription;
    @XmlElement(required = true)
    @XmlSchemaType(name = "dateTime")
    protected Date addedDate;
    @XmlElement(required = true)
    protected Feed.Userlist userlist;

    public Feed(int feedId, String url, String title, String decription, Date addedDate) {
        this.feedId = feedId;
        this.url = url;
        this.title = title;
        this.decription = decription;
        this.addedDate = addedDate;
    }

    public Feed(int feedId, String title, String decription) {
        this.feedId = feedId;
        this.title = title;
        this.decription = decription;
    }

    public Feed() {
    }

    /**
     * Gets the value of the feedId property.
     * 
     * @return
     *     possible object is
     *     {@link BigInteger }
     *     
     */
    public int getFeedId() {
        return feedId;
    }

    /**
     * Sets the value of the feedId property.
     * 
     * @param value
     *     allowed object is
     *     {@link BigInteger }
     *     
     */
    public void setFeedId(int value) {
        this.feedId = value;
    }

    /**
     * Gets the value of the url property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getUrl() {
        return url;
    }

    /**
     * Sets the value of the url property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setUrl(String value) {
        this.url = value;
    }

    /**
     * Gets the value of the title property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getTitle() {
        return title;
    }

    /**
     * Sets the value of the title property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setTitle(String value) {
        this.title = value;
    }

    /**
     * Gets the value of the decription property.
     * 
     * @return
     *     possible object is
     *     {@link String }
     *     
     */
    public String getDecription() {
        return decription;
    }

    /**
     * Sets the value of the decription property.
     * 
     * @param value
     *     allowed object is
     *     {@link String }
     *     
     */
    public void setDecription(String value) {
        this.decription = value;
    }

    /**
     * Gets the value of the addedDate property.
     * 
     * @return
     *     possible object is
     *     {@link XMLGregorianCalendar }
     *     
     */
    public Date getAddedDate() {
        return addedDate;
    }

    /**
     * Sets the value of the addedDate property.
     * 
     * @param value
     *     allowed object is
     *     {@link XMLGregorianCalendar }
     *     
     */
    public void setAddedDate(Date value) {
        this.addedDate = value;
    }

    /**
     * Gets the value of the userlist property.
     * 
     * @return
     *     possible object is
     *     {@link Feed.Userlist }
     *     
     */
    public Feed.Userlist getUserlist() {
        if (userlist == null) {
            userlist = new Userlist();
        }
        return userlist;
    }

    /**
     * Sets the value of the userlist property.
     * 
     * @param value
     *     allowed object is
     *     {@link Feed.Userlist }
     *     
     */
    public void setUserlist(Feed.Userlist value) {
        this.userlist = value;
    }

    public boolean isOwnedByUser(int userID) {
        return this.getUserlist().getUserId().contains(userID);
    }

    /**
     * <p>Java class for anonymous complex type.
     * 
     * <p>The following schema fragment specifies the expected content contained within this class.
     * 
     * <pre>
     * &lt;complexType>
     *   &lt;complexContent>
     *     &lt;restriction base="{http://www.w3.org/2001/XMLSchema}anyType">
     *       &lt;sequence>
     *         &lt;element name="userId" type="{http://www.w3.org/2001/XMLSchema}positiveInteger" maxOccurs="unbounded"/>
     *       &lt;/sequence>
     *     &lt;/restriction>
     *   &lt;/complexContent>
     * &lt;/complexType>
     * </pre>
     * 
     * 
     */
    @XmlAccessorType(XmlAccessType.FIELD)
    @XmlType(name = "", propOrder = {
        "userId"
    })
    public static class Userlist {

        @XmlElement(required = true)
        @XmlSchemaType(name = "positiveInteger")
        protected List<Integer> userId;

        /**
         * Gets the value of the userId property.
         * 
         * <p>
         * This accessor method returns a reference to the live list,
         * not a snapshot. Therefore any modification you make to the
         * returned list will be present inside the JAXB object.
         * This is why there is not a <CODE>set</CODE> method for the userId property.
         * 
         * <p>
         * For example, to add a new item, do as follows:
         * <pre>
         *    getUserId().add(newItem);
         * </pre>
         * 
         * 
         * <p>
         * Objects of the following type(s) are allowed in the list
         * {@link BigInteger }
         * 
         * 
         */
        public List<Integer> getUserId() {
            if (userId == null) {
                userId = new ArrayList<Integer>();
            }
            return this.userId;
        }

        public void setUserId(List<Integer> userId) {
            this.userId = userId;
        }
    }
}
